
const roleRoutes = {
  admin: [
    {
      path: '/',
      redirect: '/home',
      componentName: 'Layout',
      children: [
        {
          path: 'home',
          name: 'Home',
          componentName: 'Home',
          meta: {
            title: 'Home', icon: 'home', affix: true
          }
        }

      ]
    },
    {
      path: '/user-center',
      componentName: 'Layout',
      children: [
        {
          path: 'index',
          componentName: 'UserCenter',
          name: 'UserCenter',
          meta: { title: 'UserCenter', icon: 'user-center' }
        }
      ]
    },
    {
      path: '/user-management',
      componentName: 'Layout',
      children: [
        {
          path: 'index',
          componentName: 'UserManagement',
          name: 'UserManagement',
          meta: { title: 'UserManagement', icon: 'user-management' }
        }
      ]
    }
  ]
}

module.exports = [
  {
    url: '/vue-next-element-plus-admin/router/get-routes',
    type: 'post',
    response: config => {
      const { role } = config.body
      const routes = roleRoutes[role]
      if (!routes) {
        return {
          code: 50000,
          data: {},
          message: '路由获取失败，请检查用户信息'
        }
      }
      return {
        code: 20000,
        data: routes,
        message: '路由获取成功'
      }
    }
  }
]
